package com.wh.controller.storehousemanage;


import com.wh.pojo.InStorehouse;
import com.wh.service.instorehouse.PutInService;
import com.wh.vo.PageResult;
import com.wh.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/putIn/")
public class PutInController {

    @Autowired
    private PutInService putInService;

    @GetMapping("getQuery")
    public SysResult getQuery(InStorehouse inStorehouse){
        Map<String,Object> map = putInService.getQuery(inStorehouse);
        return SysResult.success(map);
    }

    @PostMapping("addInStorehouse")
    public SysResult addInStorehouse(@RequestBody InStorehouse inStorehouse){
        String data = putInService.addInStorehouse(inStorehouse);
        return SysResult.success(data);
    }

    @GetMapping("list")
    public SysResult getInStorehouseList(PageResult pageResult){
        pageResult = putInService.getInStorehouseList(pageResult);
        return SysResult.success(pageResult);
    }

    @PutMapping("updataInStorehouse")
    public SysResult updataInStorehouse(@RequestBody InStorehouse inStorehouse){
//        System.out.println(inStorehouse);
        putInService.updataInStorehouse(inStorehouse);
        return SysResult.success();
    }

    @DeleteMapping("deleteInStorehouse/{inStorehouseId}/{receivingId}")
    public SysResult deleteInStorehouse(@PathVariable String inStorehouseId,@PathVariable String receivingId){
        String data = putInService.deleteInStorehouse(inStorehouseId,receivingId);
        return SysResult.success(data);
    }



}
